// pages/my/my.js
// import iconimg from '../image/icon_leijishouyi_50x50.png'
import * as echarts from '../conmen/ec-canvas/echarts';
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isidtypeshow:false,
    // 0游客 1企业 2业务员 3代理商 4岩板砖家 5店长 6瓦工 7客户 8设计师
    // userid:app.globalData.userId,
    identity: -11,
    selectqora: 1,
    Imageurl: app.globalData.Imageurl,
    quantityoramount: [{
      test: '金额(元)',
      index: 0
    }, {
      test: '单数(单)',
      index: 1
    }],

    // ehart转成图片
    echartImgSrc:'',



    // 瓦工奖励进度
    totalreward: 1000,
    rewardprogress: 200,
    //表格滚动的多少
    isrollleft: true,
    awith: 0,
    bwith: 0,
    chartdata5: [
      ['name', '750x1500', '900x1800', '800x2600', '1200x2400'],
      ['一月', 43.3, 85.8, 93.7, 129],
      ['二月', 83.1, 73.4, 55.1, 151],
      ['三月', 86.4, 65.2, 82.5, 150],
      ['四月', 72.4, 53.9, 39.1, 150],
      ['五月', 72.4, 53.9, 39.1, 150],
      ['六月', 72.4, 53.9, 39.1, 150],
      ['三月', 86.4, 65.2, 82.5, 150],
      ['9月', 72.4, 53.9, 39.1, 150],
      ['10月', 72.4, 53.9, 39.1, 150],
      ['11月', 72.4, 53.9, 39.1, 150],
    ],
    isonLoad: true,
    isfujin: false,
    isshowyyfw:false,
    X:168,
    connectionindex:0,
    teamList: [],

    issuccessMask:false,
    addishow:false,
    isdelMask:false,
    familyId:'',
    phone:'',
    //表格有无数据-true-or-false
    nochartdata3:true,
    nochartdata1:true,
    
    
  },
  bt1(){
console.log('点击1')
  },
  bt2(){
    console.log('点击2')
  },


  binddel(e){
    let id=e.currentTarget.dataset.id

    let t=this
    wx.showModal({
      content: '是否确认删除该成员？',
      confirmColor: "#D6000F",
      success (res) {
        if (res.confirm) {
          t.delFamily(id)
        } else if (res.cancel) {
         
        }
      }
    })
 
 
  },
  // 删除家属
delFamily(familyId){  
  let t = this

  wx.showLoading({
    title: '加载中...', //提示的内容
    mask: true //显示透明蒙层 防止触摸穿透
  })

  wx.request({
    url: app.globalData.Interfaceurl + 'delFamily',
    method: "post",
    header: {
      "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
    },
    data: {
      userId: app.globalData.userId,
      token:t.data.token,
      familyId:familyId,
    },
    success: res => {
      wx.hideLoading();
      console.log(res)
      
    
    if(res.data.result==0){
    
      t.setData({
        isdelMask:true,
      })
    }else{
      wx.showToast({
        title: res.data.message,
        duration: 2500, //持续的时间
            icon: 'none', //图标
      })
    }

    },
    fail: err => {
      wx.showToast({
        title: '请求失败',
        duration: 2500, //持续的时间
            icon: 'none', //图标
      })
    }
  })
},




  // 9.76.家属列表
  getFamilyList() {
    let t = this

    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })

    wx.request({
      url: app.globalData.Interfaceurl + 'getFamilyList',
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,

      },
      success: res => {
        wx.hideLoading();
        console.log(res)
        res.data.familyList.map(item=>item.isshow=false)
        t.setData({
          teamList : res.data.familyList
        })
      },
      fail: err => {
        wx.showToast({
          title: '请求失败',
          duration: 2500, //持续的时间
          icon: 'none', //图标
        })
      }
    })
  },
  // 74.添加/修改家属
  saveFamily() {
    let t = this
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })

    wx.request({
      url: app.globalData.Interfaceurl + 'saveFamily',
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        token:t.data.token,
        name:t.data.name,
        familyId:t.data.familyId,
        mobile:t.data.phone
      },
      success: res => {
        wx.hideLoading();
        console.log(res)
       
      
        t.setData({
          addishow:false,
          issuccessMask:true
        })

      },
      fail: err => {
        wx.showToast({
          title: '请求失败',
          duration: 2500, //持续的时间
            icon: 'none', //图标
        })
      }
    })
  },



  hideaddishow(){
    this.setData({
      addishow:false,
      name:'',
      phone:'',
      familyId:'',
    })
  },
  HidesuccessMask(){
    this.setData({
      issuccessMask:false,
      name:'',
      phone:'',
      familyId:''
    })
    this.getFamilyList()
  },


  HidedelMask(){
    this.setData({
      isdelMask:false
    })
    this.getFamilyList()
  },


  sumbit(){
    if (this.data.name == '') {
      wx.showToast({
        title: '请输入姓名',
        duration: 2500, //持续的时间
        icon: 'none', //图标
      })
      return
    }
    if (this.data.phone == '') {
      wx.showToast({
        title: '请输入手机号',
        duration: 2500, //持续的时间
        icon: 'none', //图标
      })
      return
    }
    this.saveFamily()
  },




  bindPlone(e) {
    console.log(e)
    let phone = e.detail.value
    let phoneCodeVerification = /^[1][0-9]{10}$/;
    if (!phoneCodeVerification.test(phone)) {
      wx.showToast({
        title: '您输入手机号码输入不正确',
        duration: 2500, //持续的时间
            icon: 'none', //图标
      })
      this.setData({
        phone: ""
      })
    } else {

    }

  },





  addteam(e){
    if(e.currentTarget.dataset.item){
      let item=e.currentTarget.dataset.item
      this.setData({
        familyId:item.id,
        name:item.name,
        phone:item.mobile
      })
    }
    this.setData({
      addishow:true
    })
  },







  bindconnectiontype(e){
    let index=e.currentTarget.dataset.index
    this.setData({
      connectionindex:index,
   
    })
    if(e.currentTarget.dataset.index==1){
      this.setData({
        X:542
      })
    }else{
      this.setData({
        X:168
      })
    }
  },

  boda(e) {
    let plone = e.currentTarget.dataset.plone
    wx.makePhoneCall({
      phoneNumber: plone //仅为示例，并非真实的电话号码
    })
  },
  godtail(e) {
    let orderId = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/projectDetails/projectDetails?orderId=' + orderId,
    })
  },

  dinwei() {
    let t = this
    wx.getSetting({
      success(res) {
        let authSetting = res.authSetting
        if (res.authSetting['scope.userLocation'] == false) {
          wx.showModal({
            title: '提示',
            title: '您拒绝了定位权限,此功能需要授权定位,请授权',
            success() {
              wx.openSetting({
                success(res) {
                  console.log(res.authSetting)
                }
              })
            }
          })

        }

      }
    })

  },


  ykorkhfun(e) {
    if (this.data.kyselectindex == e.currentTarget.dataset.index) {
      return
    }
    this.setData({
      kyselectindex: e.currentTarget.dataset.index
    })
  },
  gomylist(e) {
    console.log(e)
    if (this.data.identity==5||this.data.identity==10) {
      wx.navigateTo({
        url: '/pages/my/pojectlist/pojectlist?type=' + e.currentTarget.dataset.type + '&identity=' + this.data.identity + '&title=' + e.currentTarget.dataset.title + '&selectqora=' + e.currentTarget.dataset.select +'&userid='+e.currentTarget.dataset.userid+'&qqtype=' + JSON.stringify(e.currentTarget.dataset.qqtype)
      })
      return
    }
    if (this.data.identity==4) {
      wx.navigateTo({
        url: '/pages/my/pojectlist/pojectlist?type=' + e.currentTarget.dataset.type + '&identity=' + this.data.identity + '&title=' + e.currentTarget.dataset.title + '&selectqora=' + e.currentTarget.dataset.select +'&userid='+e.currentTarget.dataset.userid+ '&qqtype=' + JSON.stringify(e.currentTarget.dataset.qqtype)
      })
      return
    }
    // if(this.data.ide)
    wx.navigateTo({
      url: '/pages/my/mylist/mylist?type=' + e.currentTarget.dataset.type + '&identity=' + this.data.identity + '&title=' + e.currentTarget.dataset.title + '&selectqora=' + e.currentTarget.dataset.select + '&qqtype=' + JSON.stringify(e.currentTarget.dataset.qqtype)
    })
  },
  gomylistpeple(e) {
    // if (this.data.identity == 3 && e.currentTarget.dataset.type == 3) {
    //   return
    // }
    // if (this.data.identity == 3 && e.currentTarget.dataset.type == 1) {
    //   return
    // }
    wx.navigateTo({
      url: '/pages/my/mylist/mylist?type=' + e.currentTarget.dataset.type + '&identity=' + this.data.identity + '&title=' + e.currentTarget.dataset.title,
    })
  },
  init() {


    if (this.data.identity == 1 || this.data.identity == 2 || this.data.identity == 3) {

      this.echartsComponnet = this.selectComponent('#mychart-dom-bar');
      this.init_echarts(this.getOption(this.data.chartdata1))
      // this.echartsComponnet = this.selectComponent('#mychart-dom-bar3');
      // this.init_echarts(this.getOption3(this.data.chartdata3))

    }
    if (this.data.identity == 3 || this.data.identity == 4 || this.data.identity == 5 || this.data.identity == 6 || this.data.identity == 8) {
      // this.echartsComponnet = this.selectComponent('#mychart-dom-bar4');
      // this.init_echarts(this.getOption4(this.data.chartdata4))
    }


  },

  getuserinfofun() {
    let that = this
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + 'getUserInfo',
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        that.setData({
          weather: res.data.weather,
          username: res.data.user.name,
          user:res.data.user,
          userwximage: res.data.user.wxHeadImage,
          identity: res.data.user.identity,
          userid:res.data.user.id,
        })
        if(res.data.user.identity==6){
          that.setData({
            worktype:res.data.user.workType
          })
        }
        // that.init()

      }
    })
  },
  // 0游客 1企业 2业务员 3代理商 4岩板砖家 5店长 6瓦工 7客户 8设计师
  getinformation(identity) {
    let date = new Date()
    let quarter = ''
    console.log(identity)
    switch (identity) {
      case '0':
        // 游客，客户，参数
        this.setData({
          testlx: [{
              title: '推荐案例',
              index: 0
            },
            {
              title: '最近预览',
              index: 1
            }
          ],
          kyselectindex: 0,
        })

        break;
      case '1':
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1,
          type: 2,
          xhyear: date.getFullYear(),
          echartlength: 0,
          selectchart: 1, //（企业-业务员-代理商）表格切换
          //（企业-业务员-代理商）表格标题
          charttitle: [{
            test: '趋势',
            index: 0
          }, {
            test: '占比',
            index: 1
          }],
          // 营业额选择
          selectchartyye: 0,
          charttitleyye: [{
            test: '月度',
            index: 0
          }, {
            test: '季度',
            index: 1
          }, {
            test: '年度',
            index: 2
          }
        
        ],
        //人员选择
        selectchartry: 0,
          charttitlery: [{
            test: '月度',
            index: 0
          }, {
            test: '季度',
            index: 1
          }, {
            test: '年度',
            index: 2
          }
        
        ],
        // 工地选择
        selectchartgd: 0,
          charttitlegd: [{
            test: '月度',
            index: 0
          }, {
            test: '季度',
            index: 1
          }, {
            test: '年度',
            index: 2
          }
        
        ],
          //扇形图的数据结构
          chartdata1: [{
              value: 1048,
              name: '1',
            },
            {
              value: 735,
              name: '2'
            },
            {
              value: 580,
              name: '3'
            },
            {
              value: 484,
              name: '5'
            },
            {
              value: 300,
              name: '6'
            }
          ],
          chartdata2lenght: 0,
          chartdata2: [
            ['name', '750x1500', '900x1800', '800x2600', '1200x2400'],
            ['一月', 43.3, 85.8, 93.7, 129],
            ['二月', 83.1, 73.4, 55.1, 151],
            ['三月', 86.4, 65.2, 82.5, 150],
            ['四月', 72.4, 53.9, 39.1, 150],
            ['五月', 72.4, 53.9, 39.1, 150],
            ['六月', 72.4, 53.9, 39.1, 150],
          ],
          chartdata3: {
            num: [18, 23, 294, 170, 744, 630, 23, 294, 170, 744, 294, 170, 744, 294, 170, 800],
            title: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World']
          },
          // 人员切换
    titletlistry:[
      {
        index:0,
        test:'代理商'
      },
      {
        index:1,
        test:'监理'
      },
      {
        index:2,
        test:'瓦工'
      },
      
    ],
    selectindexry:0,
    
    //  titlelenght:this.data.titletlistry.length
        })
        
        this.getdatafun('getEnterpriseProjectCollect')
        this.getProductSpecPieChart(this.data.type, this.data.year)
        this.getProductModelBarChart(this.data.xhyear)
        this.getTurnoverLine(1)
        this.getPersonLine(1,3)
        this.getProjectLine(1)




        



        break;
      case '2':
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 + '月',
          type: 2,
          xhyear: date.getFullYear(),
          echartlength: 0,
          selectchart: 1, //（企业-业务员-代理商）表格切换
          //（企业-业务员-代理商）表格标题
          charttitle: [{
            test: '趋势',
            index: 0
          }, {
            test: '占比',
            index: 1
          }],
          //扇形图的数据结构
          chartdata1: [{
              value: 1048,
              name: '1',
            },
            {
              value: 735,
              name: '2'
            },
            {
              value: 580,
              name: '3'
            },
            {
              value: 484,
              name: '5'
            },
            {
              value: 300,
              name: '6'
            }
          ],
          chartdata2lenght: 0,
          chartdata2: [
            ['name', '750x1500', '900x1800', '800x2600', '1200x2400'],
            ['一月', 43.3, 85.8, 93.7, 129],
            ['二月', 83.1, 73.4, 55.1, 151],
            ['三月', 86.4, 65.2, 82.5, 150],
            ['四月', 72.4, 53.9, 39.1, 150],
            ['五月', 72.4, 53.9, 39.1, 150],
            ['六月', 72.4, 53.9, 39.1, 150],
          ],
          chartdata3: {
            num: [18, 23, 294, 170, 744, 630, 23, 294, 170, 744, 294, 170, 744, 294, 170, 800],
            title: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World']
          },
           // 营业额选择
           selectchartyye: 0,
           charttitleyye: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
         //人员选择
         selectchartry: 0,
           charttitlery: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
         // 工地选择
         selectchartgd: 0,
           charttitlegd: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
           // 人员切换
    titletlistry:[
      {
        index:0,
        test:'代理商'
      },
      {
        index:1,
        test:'监理'
      },
      {
        index:2,
        test:'瓦工'
      },
      
    ],
    selectindexry:0,
        })
        this.getdatafun('getSalesmanProjectCollect')
        this.getProductSpecPieChart(this.data.type, this.data.year)
        this.getProductModelBarChart(this.data.xhyear,true)

        this.getTurnoverLine(1)
        this.getPersonLine(1,3)
        this.getProjectLine(1)
        break;
      case '3':
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 + '月',
          type: 2,
          xhyear: date.getFullYear(),
          echartlength: 0,
          selectchart: 1, //（企业-业务员-代理商）表格切换
          //（企业-业务员-代理商）表格标题
          charttitle: [{
            test: '趋势',
            index: 0
          }, {
            test: '占比',
            index: 1
          }],
          //扇形图的数据结构
          chartdata1: [{
              value: 1048,
              name: '1',
            },
            {
              value: 735,
              name: '2'
            },
            {
              value: 580,
              name: '3'
            },
            {
              value: 484,
              name: '5'
            },
            {
              value: 300,
              name: '6'
            }
          ],
          chartdata2lenght: 0,
          chartdata2: [
            ['name', '750x1500', '900x1800', '800x2600', '1200x2400'],
            ['一月', 43.3, 85.8, 93.7, 129],
            ['二月', 83.1, 73.4, 55.1, 151],
            ['三月', 86.4, 65.2, 82.5, 150],
            ['四月', 72.4, 53.9, 39.1, 150],
            ['五月', 72.4, 53.9, 39.1, 150],
            ['六月', 72.4, 53.9, 39.1, 150],
          ],
          chartdata3: {
            num: [18, 23, 294, 170, 744, 630, 23, 294, 170, 744, 294, 170, 744, 294, 170, 800],
            title: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World', 'India', 'China', 'World']
          },
           // 营业额选择
           selectchartyye: 0,
           charttitleyye: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
         //人员选择
         selectchartry: 0,
           charttitlery: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
         // 工地选择
         selectchartgd: 0,
           charttitlegd: [{
             test: '月度',
             index: 0
           }, {
             test: '季度',
             index: 1
           }, {
             test: '年度',
             index: 2
           }
         
         ],
           // 人员切换
    titletlistry:[
      
      {
        index:0,
        test:'监理'
      },
      {
        index:1,
        test:'瓦工'
      },
      
    ],
    selectindexry:0,
        })
        this.getdatafun('getAgentProjectCollect')
        this.getProductSpecPieChart(this.data.type, this.data.year)
        this.getProductModelBarChart(this.data.xhyear,true)

        this.getTurnoverLine(1)
        this.getPersonLine(1,4)
        this.getProjectLine(1)
        break;
      case '4':
        // 设置表报年份
        if ((date.getMonth() + 1) <= 3) {
          quarter = '第一季度'
        } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
          quarter = '第二季度'
        } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
          quarter = '第三季度'
        } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
          quarter = '第四季度'
        }
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 ,
          quarter: quarter,
          tablename: '我的工地',
          type: 1,
          pageNo: 1,
          pageSize: 10,
          selectcharttwo: 0,
          charttitletwo: [{
            test: '按月',
            index: 0
          }, {
            test: '按季度',
            index: 1
          }],
          chartdata4: {
            num: [50, 10, 18, 20, 21, 15, 19, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          },
          chartdata5: {
            num: [10, 52, 200, 334],
            month: ['1月季度', '2月季度', '3月季度', '4月季度']
          }
        })
        this.getdatafun('getSuperviseProjectCollect')
        this.getProjectColumn(this.data.type, this.data.year, 'getSuperviseProjectColumn')
        this.getSuperviseFinishProjectPage()
        break;
      case '5':
        // 设置表报年份
        if ((date.getMonth() + 1) <= 3) {
          quarter = '第一季度'
        } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
          quarter = '第二季度'
        } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
          quarter = '第三季度'
        } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
          quarter = '第四季度'
        }
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 ,
          quarter: quarter,
          tablename: '我的项目',
          type: 1,
          pageNo: 1,
          pageSize: 10,
          selectcharttwo: 0,
          charttitletwo: [{
            test: '月份',
            index: 0
          }, {
            test: '季度',
            index: 1
          }],
          chartdata4: {
            num: [50, 10, 18, 20, 21, 15, 19, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          },
          chartdata5: {
            num: [10, 52, 200, 334],
            month: ['1月季度', '2月季度', '3月季度', '4月季度']
          }
        })
        this.getdatafun('getShopownerProjectCollect')
        this.getProjectColumn(this.data.type, this.data.year, 'getShopownerProjectColumn')
        this.getShopownerFinishProjectPage()
        break;
      case '6':
        // 设置表报年份

        if ((date.getMonth() + 1) <= 3) {
          quarter = '第一季度'
        } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
          quarter = '第二季度'
        } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
          quarter = '第三季度'
        } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
          quarter = '第四季度'
        }
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 ,
          quarter: quarter,
          tablename: '我的工地',
          type: 1,
          pageNo: 1,
          pageSize: 10,
          selectcharttwo: 0,
          charttitletwo: [{
            test: '月份',
            index: 0
          }, {
            test: '季度',
            index: 1
          }],
          chartdata4: {
            num: [50, 10, 18, 20, 21, 15, 19, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          },
          chartdata5: {
            num: [10, 52, 200, 334],
            month: ['1月季度', '2月季度', '3月季度', '4月季度']
          }
        })
        this.getdatafun('getBricklayProjectCollect')
        this.getProjectColumn(this.data.type, this.data.year, 'getBricklayProjectColumn')
        this.getBricklayFinishProjectPage()
        break;
      case '7':
        // 游客，客户，参数
        this.setData({
          testlx: [{
              title: '推荐案例',
              index: 0
            },
            {
              title: '最近预览',
              index: 1
            }
          ],
          titlelenght: 2,
          kyselectindex: 0,
        })
        break;
      case '8':
        // 设置表报年份

        if ((date.getMonth() + 1) <= 3) {
          quarter = '第一季度'
        } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
          quarter = '第二季度'
        } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
          quarter = '第三季度'
        } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
          quarter = '第四季度'
        }
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 + '月',
          quarter: quarter,
          tablename: '我的作品',
          type: 1,
          pageNo: 1,
          pageSize: 10,
          selectcharttwo: 0,
          charttitletwo: [{
            test: '月份',
            index: 0
          }, {
            test: '季度',
            index: 1
          }],
          chartdata4: {
            num: [50, 10, 18, 20, 21, 15, 19, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          },
          chartdata5: {
            num: [10, 52, 200, 334],
            month: ['1月季度', '2月季度', '3月季度', '4月季度']
          }
        })
        this.getdatafun('getDesignerProjectCollect')
        this.getProjectColumn(this.data.type, this.data.year, 'getDesignerProjectColumn')
        this.getDesignerFinishProjectPage()

        break;
      case '9':
        console.log(2)
        break;
      case '10':
         // 设置表报年份
         if ((date.getMonth() + 1) <= 3) {
          quarter = '第一季度'
        } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
          quarter = '第二季度'
        } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
          quarter = '第三季度'
        } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
          quarter = '第四季度'
        }
        this.setData({
          year: date.getFullYear(),
          month: date.getMonth() + 1 ,
          quarter: quarter,
          tablename: '我的项目',
          type: 1,
          pageNo: 1,
          pageSize: 10,
          selectcharttwo: 0,
          charttitletwo: [{
            test: '月份',
            index: 0
          }, {
            test: '季度',
            index: 1
          }],
          chartdata4: {
            num: [50, 10, 18, 20, 21, 15, 19, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          },
          chartdata5: {
            num: [10, 52, 200, 334],
            month: ['1月季度', '2月季度', '3月季度', '4月季度']
          }
        })
        this.getdatafun('getAdviserProjectCollect')
        this.getProjectColumn(this.data.type, this.data.year, 'getAdviserProjectColumn')
        this.getAdviserFinishProjectPage()
        break;
      default:
        break;
    }
  },
  leftfun2() {

    this.setData({
      year: this.data.year - 1,
      month: '',
    })
    this.getProductSpecPieChart(this.data.type, this.data.year)
    this.getProductModelBarChart(this.data.year)

  },
  rightfun2() {
    let date = new Date()
    if (date.getFullYear() == this.data.year) {
      wx.showToast({
        title: '查询不到明年数据',
        duration: 2500, //持续的时间
        icon: 'none', //图标
      })
      return
    }

    this.setData({
      year: this.data.year + 1
    })
    this.getProductSpecPieChart(this.data.type, this.data.year)
    this.getProductModelBarChart(this.data.year)
  },

  leftfun() {

    this.setData({
      year: this.data.year - 1,
      month: '',
      quarter: ''
    })
    switch (this.data.identity) {
      case '4':
        this.getProjectColumn(this.data.type, this.data.year, 'getSuperviseProjectColumn')
        break;
      case '5':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getShopownerProjectColumn')
        break;
      case '6':
        this.getProjectColumn(this.data.type, this.data.year, 'getBricklayProjectColumn')
        break;
      case '8':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getDesignerProjectColumn')
        break;
      case '10':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getAdviserProjectColumn')
        break;

      default:
        break;
    }
  },
  rightfun() {
    let date = new Date()
    if (date.getFullYear() == this.data.year) {
      return
    }

    this.setData({
      year: this.data.year + 1
    })
    let quarter = ''
    if (date.getFullYear() == this.data.year) {

      if ((date.getMonth() + 1) <= 3) {
        quarter = '第一季度'
      } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
        quarter = '第二季度'
      } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
        quarter = '第三季度'
      } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
        quarter = '第四季度'
      }
      this.setData({
        month: date.getMonth() + 1 + '月',
        quarter: quarter
      })
    }
    switch (this.data.identity) {
      case '4':
        this.getProjectColumn(this.data.type, this.data.year, 'getSuperviseProjectColumn')
        break;
      case '5':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getShopownerProjectColumn')
        break;
      case '6':
        this.getProjectColumn(this.data.type, this.data.year, 'getBricklayProjectColumn')
        break;
      case '8':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getDesignerProjectColumn')
        break;
      case '10':
        console.log(1)
        this.getProjectColumn(this.data.type, this.data.year, 'getAdviserProjectColumn')
        break;

      default:
        break;
    }
  },
  //瓦工作品
  getBricklayFinishProjectPage() {
    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getBricklayFinishProjectPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
      },
      success(res) {
        console.log(res)
        that.setData({
          datalist: res.data.page.list,
          toalpages: Math.ceil(res.data.page.count / that.data.pageSize)
          // toalpages:5
        })
      }
    })
  },


  //店长作品
  getShopownerFinishProjectPage() {
    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getShopownerFinishProjectPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
      },
      success(res) {
        console.log(res)
        that.setData({
          datalist: res.data.page.list,
          toalpages: Math.ceil(res.data.page.count / that.data.pageSize)
          // toalpages:5
        })
      }
    })
  },
   //家居顾问作品
   getAdviserFinishProjectPage() {
    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getAdviserFinishProjectPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
      },
      success(res) {
        console.log(res)
        that.setData({
          datalist: res.data.page.list,
          toalpages: Math.ceil(res.data.page.count / that.data.pageSize)
          // toalpages:5
        })
      }
    })
  },
  //岩板砖家作品
  getSuperviseFinishProjectPage() {
    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getSuperviseFinishProjectPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
      },
      success(res) {
        console.log(res)
        that.setData({
          datalist: res.data.page.list,
          toalpages: Math.ceil(res.data.page.count / that.data.pageSize)
          // toalpages:5
        })
      }
    })
  },
  //设计师作品
  getDesignerFinishProjectPage() {
    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getDesignerFinishProjectPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
      },
      success(res) {
        console.log(res)
        that.setData({
          datalist: res.data.page.list,
          toalpages: Math.ceil(res.data.page.count / that.data.pageSize)
          // toalpages:5
        })
      }
    })
  },
  //店长报表
  getShopownerProjectColumn(type, year) {

    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + "getShopownerProjectColumn",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type: type,
        year: year,
      },
      success(res) {
        console.log(res)
        let date = new Date()
        if (that.data.type == 1) {
          if (that.data.year == date.getFullYear()) {
            res.data.numList.forEach((element, index) => {
              if (index > date.getMonth()) {
                res.data.numList[index] = ''
              }
            });
          }
          // res.data.dateList.forEach((element,index) => {
          //   res.data.dateList[index]=element+'月'
          // });
          let chartdata = {
            // num:res.data.numList,
            // month:res.data.dateList
            num: [50, 10, 18, 20, 21, 15, 0, 43, 28, 29, 40, 41],
            month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          }
          that.setData({
            chartdata4: chartdata
          })
          that.echartsComponnet = that.selectComponent('#mychart-dom-bar4');
          that.init_echarts(that.getOption4(that.data.chartdata4))
          // that.echartroll()
        } else {





          if (that.data.year == date.getFullYear()) {
            if ((date.getMonth() + 1) <= 3) {
              res.data.numList[1] = ''
              res.data.numList[2] = ''
              res.data.numList[3] = ''
            } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
              res.data.numList[2] = ''
              res.data.numList[3] = ''
            } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
              res.data.numList[3] = ''
            }
          }
          let chartdata = {
            num: res.data.numList,
            month: res.data.dateList
          }

          that.setData({
            chartdata5: chartdata
          })

          that.echartsComponnet = that.selectComponent('#mychart-dom-bar5');
          that.init_echarts(that.getOption5(that.data.chartdata5))
          // that.echartroll()

        }

      }
    })
  },
  //<!-- 瓦工 店长 岩板砖家 店长 图表方法 -->
  getProjectColumn(type, year, tableurl) {

    let that = this
    wx.request({
      url: app.globalData.Interfaceurl + tableurl,
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type: type,
        year: year,
      },
      success(res) {
        console.log(res)
        let date = new Date()
        if (that.data.type == 1) {
          if (that.data.year == date.getFullYear()) {
            that.setData({
              selectmonth:date.getMonth(),
              month:date.getMonth()+1
            })
            res.data.numList.forEach((element, index) => {
              if (index > date.getMonth()) {
                res.data.numList[index] = ''
              }
            });
          }else{
            that.setData({
              selectmonth:-1,
              month:''
            })
          }
          if (res.data.dateList.length > 7) {
            that.setData({
              echartlength: res.data.dateList.length - 8
            })
          }
          // res.data.dateList.forEach((element,index) => {
          //   res.data.dateList[index]=element+'月'
          // });
          let chartdata = {
            num: res.data.numList,
            month: res.data.dateList
            // num:[50, 10, 18, 20, 21, 15, 0, 43, 28, 29, 40, 41],
            // month: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
          }
          that.setData({
            chartdata4: chartdata,
            monthindex: date.getMonth()
          })
          that.echartsComponnet = that.selectComponent('#mychart-dom-bar4');
          that.init_echarts(that.getOption4(that.data.chartdata4))
          if (that.data.year == date.getFullYear()) {
          if(date.getMonth()+1>8){
            that.setData({
              scrollleft:500
            })
          }
        }else{
          that.setData({
            scrollleft:0
          })
        }
          
          // console.log('dsasda',that.echartsComponnet.chart)
          // that.echartsComponnet.chart.on('click', (params) => {
          //   console.log(params)
          // })
          // that.echartsComponnet = that.selectComponent('#mychart-dom-bar6');
          // that.init_echarts(that.getOption4(that.data.chartdata4))
          // that.echartroll()

        } else {





          if (that.data.year == date.getFullYear()) {
            if ((date.getMonth() + 1) <= 3) {
              res.data.numList[1] = ''
              res.data.numList[2] = ''
              res.data.numList[3] = ''
            } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
              res.data.numList[2] = ''
              res.data.numList[3] = ''
            } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
              res.data.numList[3] = ''
            }
          }
          let chartdata = {
            num: res.data.numList,
            month: res.data.dateList
          }

          that.setData({
            chartdata5: chartdata
          })

          that.echartsComponnet = that.selectComponent('#mychart-dom-bar5');
          that.init_echarts(that.getOption5(that.data.chartdata5))
          // that.echartroll()

        }

        

      }
    })
  },
  // 50.企业/业务员/代理商-我的-规格饼图
  getProductSpecPieChart(type, year) {
    let that = this
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + "getProductSpecPieChart",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type: type,
        year: year,
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        let date = new Date()
        if (that.data.type == 2) {
         that.setData({
           bztlist:res.data.specRatio
         })

          let chartname = []
          let chartnum = []
          let charttotal = 0
          let chartpercentage = []
          
          if (res.data.specRatio.some(item => item.value > 0)) {
            res.data.specRatio.forEach((element, index) => {
              chartname[index] = element.name
              chartnum[index] = element.value
              charttotal = charttotal + element.value
            })
            chartnum.forEach((element, index) => {
              chartpercentage[index] = {}
              if (element == 0) {
                chartpercentage[index].name = "0%";
                chartpercentage[index].value = chartnum[index]
              } else {
                chartpercentage[index].name = Math.round(element / charttotal * 10000) / 100 + "%";
                chartpercentage[index].value = chartnum[index]
              }

            })
            that.setData({
              chartdata1: chartpercentage,
              chartname: chartname,
              nochartdata1:true
            })

          } else {
            res.data.specRatio.forEach((element, index) => {
              chartname[index] = element.name
              chartnum[index] = element.value
              charttotal = charttotal + element.value
            })
            // console.log('无数据')
            that.setData({
              chartdata1: [{
                name: '',
                value: 1
              }],
              chartname: chartname,
              nochartdata1:false

            })
          }
          that.echartsComponnet = that.selectComponent('#mychart-dom-bar');
          console.log('that.getOption(that.data.chartdata1)', that.getOption(that.data.chartdata1))
          that.init_echarts(that.getOption(that.data.chartdata1))
        } else if (that.data.type == 1) {
          console.log('chart2')
          let chartdata = res.data.specTrend
          // chartdata= [
          //   ['name', '750x1500', '900x1800', '800x2600','1200x2400'],
          //   ['一月', 43.3, 85.8, 93.7,129],
          //   ['二月', 83.1, 73.4, 55.1,151],
          //   ['三月', 86.4, 65.2, 82.5,150],
          //   ['四月', 86.4, 65.2, 82.5,150],
          //   ['五月', 86.4, 65.2, 82.5,150],
          //   ['六月', 86.4, 65.2, 82.5,150],
          //   ['七月', 86.4, 65.2, 82.5,150],
          //   ['八月', 86.4, 65.2, 82.5,150],
          //   ['九月', 86.4, 65.2, 82.5,150],
          //   ['十月', 86.4, 65.2, 82.5,150],
          //   ['十一月', 86.4, 65.2, 82.5,150],
          //   ['十二月', 86.4, 65.2, 82.5,150],
          // ]
          let charttitle = chartdata.shift()
          charttitle.shift()
          that.setData({
            chart2title: charttitle,
            chartdata2: chartdata
          })
          

         

          if (that.data.chartdata2.length > 5) {
            that.setData({
              echartlength: that.data.chartdata2.length - 6
            })
            if (that.data.year == date.getFullYear()) {
              if(date.getMonth()+1>5){
                that.setData({
                  scrollleft:800
                })
              }else{
                that.setData({
                  scrollleft:0
                })
              }
              
            }else{
              that.setData({
                scrollleft:0
              })}
            
          }
          // that.getgrechartwz2()
          // console.log(that.data.chartdata2.length)
          that.echartsComponnet = that.selectComponent('#mychart-dom-bar2');
          
          that.init_echarts(that.getOption2(that.data.chartdata2))



        }
      }
    })

  },

  scroll(e) {
    console.log(e)
    this.setData({
      jindugd: e.detail.scrollLeft
    })
  },
  // 51.企业/业务员/代理商-我的-型号柱状图
  getProductModelBarChart(year) {
    let that = this
    that.setData({
      echartImgSrc:''
    })
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + "getProductModelBarChart",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        // type:type,
        year: year,
      },
      success(res) {
        // console.log(res)
        wx.hideLoading()
        // let chartdata3={
        //   num:[18, 23, 294, 170, 744, 630, 23, 294, 170, 744, 294, 170, 744, 18004, 17000, 21000],
        //   title: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World','India', 'China', 'World','India', 'China', 'World','India', 'China', 'World']
        // }
        // return
        if(res.data.numList.length>0){
          that.setData({
            nochartdata3:false
          })
        let chartdata = {
          title: res.data.modelList,
          num: res.data.numList
        }
        // that.setData({
        //   nochartdata3:true
        // })
        // let chartdata = {
        //   title: [],
        //   num: []
        // }

        that.setData({
          chartdata3: chartdata,
          chart5lenght: res.data.numList.length
        })


        that.echartsComponnet = that.selectComponent('#mychart-dom-bar3');
        console.log(that.selectComponent('#mychart-dom-bar3'))
        that.init_echarts(that.getOption3(that.data.chartdata3),true)
      }else{
        // console.log('111')
        that.setData({
          nochartdata3:true
        })
      }

      }
    })
  },

  //个人页面营业额折线图
  getTurnoverLine(type) {
    let that = this
    
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })

    wx.request({
      url: app.globalData.Interfaceurl + "getTurnoverLine",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type:type,
        // year: year,
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        let date=new Date()
        let year=date.getFullYear()
        let month=date.getMonth() +1
        console.log('获取年月',year,month)
        
        if (type==1) {
          that.setData({
            selectmonth:month-1
          })
          
        }else if (type==2) {
          if (month<=3) {
            that.setData({
              selectmonth:0,
              month:'第一季度',
            })
          }else if(month>3&&month<=6){
            that.setData({
              selectmonth:1,
              month:'第二季度',
            })
          }else if(month>6&&month<=9){
            that.setData({
              selectmonth:2,
              month:'第三季度',
            })
          }else if(month>9&&month<=12){
            that.setData({
              selectmonth:3,
              month:'第四季度',
            })
          }
          
        }else{
          res.data.dateList.forEach((element,index) => {
            if(element==year){
              that.setData({
                selectmonth:index,
              })
            } 
          });
          that.setData({
            // selectmonth:2,
            month:year,
          })
         
        }
        that.setData({
          chartdatayye:res.data.dateList,
          numListyye:res.data.numList,
        })

        that.echartsComponnet = that.selectComponent('#mychart-dom-baryye');
      console.log('that',that)
      that.init_echarts(that.getOptionyye(that.data.chartdatayye,that.data.numListyye,type),false)

      }
    })
  },
  //个人页面人员额折线图
  getPersonLine(type,identity) {
    let that = this
    
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })

    wx.request({
      url: app.globalData.Interfaceurl + "getPersonLine",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type:type,
        selectIdentity: identity,
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        let date=new Date()
        let year=date.getFullYear()
        let month=date.getMonth() +1
        console.log('获取年月',year,month)
        
        if (type==1) {
          that.setData({
            selectmonth:month-1,
            month:month
            
          })
          
        }else if (type==2) {
          if (month<=3) {
            that.setData({
              selectmonth:0,
              month:'第一季度',
            })
          }else if(month>3&&month<=6){
            that.setData({
              selectmonth:1,
              month:'第二季度',
            })
          }else if(month>6&&month<=9){
            that.setData({
              selectmonth:2,
              month:'第三季度',
            })
          }else if(month>9&&month<=12){
            that.setData({
              selectmonth:3,
              month:'第四季度',
            })
          }
          
        }else{
          res.data.dateList.forEach((element,index) => {
            if(element==year){
              that.setData({
                selectmonth:index,
                // month:year
              })
            } 
          });
          that.setData({
            // selectmonth:2,
            month:year,
          })
         
        }
          that.setData({
            chartdatary:res.data.dateList,
            numListry:res.data.numList,
          })

        that.echartsComponnet = that.selectComponent('#mychart-dom-barry');
      console.log('that',that)
      that.init_echarts(that.getOptionry(that.data.chartdatary,that.data.numListry),false)

      }
    })
  },
  //个人页面工地额折线图
  getProjectLine(type) {
    let that = this
    
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })

    wx.request({
      url: app.globalData.Interfaceurl + "getProjectLine",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        type:type,
        // selectIdentity: identity,
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        let date=new Date()
        let year=date.getFullYear()
        let month=date.getMonth() +1
        console.log('获取年月',year,month)
        
        if (type==1) {
          that.setData({
            selectmonth:month-1
          })
          
        }else if (type==2) {
          if (month<=3) {
            that.setData({
              selectmonth:0,
              month:'第一季度',
            })
          }else if(month>3&&month<=6){
            that.setData({
              selectmonth:1,
              month:'第二季度',
            })
          }else if(month>6&&month<=9){
            that.setData({
              selectmonth:2,
              month:'第三季度',
            })
          }else if(month>9&&month<=12){
            that.setData({
              selectmonth:3,
              month:'第四季度',
            })
          }
          
        }else{
          res.data.dateList.forEach((element,index) => {
            if(element==year){
              that.setData({
                selectmonth:index,
              })
            } 
          });
          that.setData({
            // selectmonth:2,
            month:year,
          })
         
        }
          that.setData({
            chartdatagd:res.data.dateList,
            numListgd:res.data.numList,
          })

        that.echartsComponnet = that.selectComponent('#mychart-dom-bargd');
      console.log('that',that)
      that.init_echarts(that.getOptiongd(that.data.chartdatagd,that.data.numListgd),false)

      }
    })
  },


  getdatafun(url) {
    let that = this
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + url,
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId
      },
      success(res) {
        console.log(res)
        wx.hideLoading()
        that.setData({
          projectCollect: res.data.projectCollect
        })
      }
    })
  },

  //获取图表滚动的初始位置 4岩板砖家 5店长 6瓦工 8设计师
  getgrechartwz() {
    let that = this
    console.log('dsfs')
    wx.createSelectorQuery().select('.shux').boundingClientRect(function (res) {
      that.setData({
        shuxright: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.chart-four').boundingClientRect(function (res) {
      that.setData({
        chartfourright: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.textkuan').boundingClientRect(function (res) {
      console.log('111', res)
      that.setData({
        textkuan: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.textkuan-nei').boundingClientRect(function (res) {
      console.log('112', res)
      that.setData({
        textkuannei: res.right
      })
    }).exec()
  },
  //获取图表滚动的初始位置 1企业 2业务员 3代理商
  getgrechartwz2() {
    let that = this
    console.log('dsfs')
    wx.createSelectorQuery().select('.chart-bg2').boundingClientRect(function (res) {
      console.log('0echart', res)
      that.setData({
        shuxright: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.chart-two').boundingClientRect(function (res) {
      console.log('1echart', res)
      that.setData({
        chartfourright: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.textkuan').boundingClientRect(function (res) {
      console.log('111', res)
      that.setData({
        textkuan: res.right
      })
    }).exec()
    wx.createSelectorQuery().select('.textkuan-nei').boundingClientRect(function (res) {
      console.log('112', res)
      that.setData({
        textkuannei: res.right
      })
    }).exec()
  },
  //滚动

  echartroll() {
    let that = this
    if (that.data.type == 2) {
      return
    }


    wx.createSelectorQuery().select('.chart-four').boundingClientRect(function (res2) {
      that.setData({
        leftoffset: (res2.right - that.data.shuxright) / (that.data.chartfourright - that.data.shuxright)
      })

    }).exec()








  },
  echartroll2() {
    let that = this
    if (that.data.type == 2) {
      return
    }
    wx.createSelectorQuery().select('.chart-two').boundingClientRect(function (res2) {
      console.log(res2)
      that.setData({
        leftoffset: (res2.right - that.data.shuxright) / (that.data.chartfourright - that.data.shuxright)
      })

    }).exec()


  },
  touchstart(e) {
    console.log(e)
    this.setData({
      stateY: e.changedTouches[0].clientX
    })
  },
  touchend(e) {
    let touchendclientY = e.changedTouches[0].clientX
    // console.log(e)
    // let cha=touchendclientY-this.data.stateY
    // if(cha<0){
    //   this.echartroll()
    //   // this.setData({
    //   //   y:0
    //   // })
    // }else if(cha>0){
    //   this.echartroll()
    //   // this.setData({
    //   //   y:"450rpx"
    //   // })
    // }
  },
  //图表滚动 4岩板砖家 5店长 6瓦工 8设计师
  touchmove(e) {
    // this.echartroll()
  },
  touchstart2(e) {
    console.log(e)
    this.setData({
      stateY: e.changedTouches[0].clientX
    })
  },
  touchend2(e) {
    let touchendclientY = e.changedTouches[0].clientX
    let cha = touchendclientY - this.data.stateY
    if (cha < 0) {
      this.echartroll2()
      // this.setData({
      //   y:0
      // })
    } else if (cha > 0) {
      this.echartroll2()
      // this.setData({
      //   y:"450rpx"
      // })
    }
  },
  //图表滚动 1企业 2业务员 3代理商
  touchmove2(e) {
    // this.echartroll2()
  },
  // 人员切换
  titlefunry(e){
    let that=this
      
    if (this.data.selectindexry==e.currentTarget.dataset.index) {
      return
    }
    
    this.setData({
      selectindexry:e.currentTarget.dataset.index,
    })
    if (this.data.identity==3) {
      if (this.data.selectindexry==0) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+4)
      }else if (this.data.selectindexry==1) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+5)
      }
    }else{
      if (this.data.selectindexry==0) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+3)
      }else if (this.data.selectindexry==1) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+3)
      }else{
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+4)
      }
    }
    
  },


  echarttitlefun(e) {
    this.setData({
      selectchart: e.currentTarget.dataset.index
    })
    if (e.currentTarget.dataset.index == 1) {
      this.setData({
        type: 2,
        jindugd: 0,
      })
      this.getProductSpecPieChart(this.data.type, this.data.year)

    } else {
      this.setData({
        type: 1,
        jindugd: 0,
      })
      this.getProductSpecPieChart(this.data.type, this.data.year)
      console.log(this.data.chartdata2)

    }

  },
  echarttitleyyefun(e){
    this.setData({
      selectchartyye: e.currentTarget.dataset.index
    })
    console.log(e.currentTarget.dataset.index)
    // return
    
    if (e.currentTarget.dataset.index == 0) {
      
      this.getTurnoverLine(1)

    } else if(e.currentTarget.dataset.index == 1){
      this.getTurnoverLine(2)
    }else{
      this.getTurnoverLine(3)

    }
  },
  echarttitleryfun(e){
    this.setData({
      selectchartry: e.currentTarget.dataset.index
    })

    if (this.data.identity==3) {
      if (this.data.selectindexry==0) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+4)
      }else if (this.data.selectindexry==1) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+5)
      }
    }else{
      if (this.data.selectindexry==0) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+3)
      }else if (this.data.selectindexry==1) {
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+3)
      }else{
        this.getPersonLine(this.data.selectchartry+1,this.data.selectindexry+4)
      }
    }
 
  },
  echarttitlegdfun(e){
    this.setData({
      selectchartgd: e.currentTarget.dataset.index
    })
    if (e.currentTarget.dataset.index == 0) {
      
      this.getProjectLine(1)

    } else if(e.currentTarget.dataset.index == 1){
      this.getProjectLine(2)
    }else{
      this.getProjectLine(3)

    }
   
  },
  echarttwotitlefun(e) {
    let date = new Date()
    let quarter = ''
    if ((date.getMonth() + 1) <= 3) {
      quarter = '第一季度'
    } else if ((date.getMonth() + 1) >= 4 && (date.getMonth() + 1) <= 6) {
      quarter = '第二季度'
    } else if ((date.getMonth() + 1) >= 7 && (date.getMonth() + 1) <= 9) {
      quarter = '第三季度'
    } else if ((date.getMonth() + 1) >= 10 && (date.getMonth() + 1) <= 12) {
      quarter = '第四季度'
    }
    console.log(e)
    this.setData({
      selectcharttwo: e.currentTarget.dataset.index,
      // year: date.getFullYear(),
      quarter: quarter,
      month: date.getMonth() + 1 
    })
    if (e.currentTarget.dataset.index == 1) {
      this.setData({
        type: 2
      })

      switch (this.data.identity) {
        case '4':
          this.getProjectColumn(this.data.type, this.data.year, 'getSuperviseProjectColumn')
          break;
        case '5':
          console.log(1)
          this.getProjectColumn(this.data.type, this.data.year, 'getShopownerProjectColumn')
          break;
        case '6':
          this.getProjectColumn(this.data.type, this.data.year, 'getBricklayProjectColumn')
          break;
        case '8':
          console.log(1)
          this.getProjectColumn(this.data.type, this.data.year, 'getDesignerProjectColumn')
          break;
        case '10':
          console.log(1)
          this.getProjectColumn(this.data.type, this.data.year, 'getAdviserProjectColumn')
          break;

        default:
          break;
      }

    } else {

      this.setData({
        type: 1
      })
      switch (this.data.identity) {
        case '4':
          this.getProjectColumn(this.data.type, this.data.year, 'getSuperviseProjectColumn')
          break;
        case '5':
          console.log(1)
          this.getProjectColumn(this.data.type, this.data.year, 'getShopownerProjectColumn')
          break;
        case '6':
          this.getProjectColumn(this.data.type, this.data.year, 'getBricklayProjectColumn')
          break;
        case '8':
          this.getProjectColumn(this.data.type, this.data.year, 'getDesignerProjectColumn')
          break;
        case '10':
        this.getProjectColumn(this.data.type, this.data.year, 'getAdviserProjectColumn')
        break;

        default:
          break;
      }

    }

  },
  selectqorafun(e) {
    console.log(111)
    this.setData({
      selectqora: e.currentTarget.dataset.index
    })


  },



  init_echarts: function (option,image=false) {
    let that = this

    wx.getSystemInfo({
      success: function (res) {
        // const chart = echarts.init(canvas, null, {
        //     width: width,
        //     height: height,
        //     //设置图表像素比
        //     devicePixelRatio: res.pixelRatio,
        // });

        that.echartsComponnet.init((canvas, width, height) => {
          // 初始化图表
          const Chart = echarts.init(canvas, null, {
            width: width,
            height: height,
            devicePixelRatio: res.pixelRatio,
          });
          console.log('img',image)
            if(image){
              Chart.on('finished', () => {
                that.selectComponent('#mychart-dom-bar3').canvasToTempFilePath({
                  success: res => {
                    that.setData({
                      echartImgSrc: res.tempFilePath
                    })
                  },
                  fail: res => console.log('转换图片失败', res)
                });
              })
            }
          Chart.setOption(option);
            Chart.on('click', function (params) {
              // console.log('params11',params)
              params.color = "#EE6666"
              if(params.componentType=="series"){
                that.setData({
                  month:params.name,
                  // selectmonth:params.dataIndex
                })
              }
              if (params.componentType=="xAxis") {
                that.setData({
                  month:params.value,
                  // selectmonth:params.dataIndex
                })
              }
              that.setData({
                // month:params.value,
                selectmonth:params.dataIndex
              })
              // console.log(that.data.monthindex)
              // checkName = params.name;
    
              
  
              Chart.setOption(option);
            });
         
          




          return Chart;
        });
      },
      fail: function () {
        that.echartsComponnet.init((canvas, width, height) => {
          // 初始化图表
          const Chart = echarts.init(canvas, null, {
            width: width,
            height: height,
            devicePixelRatio: res.pixelRatio,
          });
          Chart.setOption(option);
          Chart.on('click', function (params) {

            Chart.setOption(option);
          });
          // 注意这里一定要返回 chart 实例，否则会影响事件处理等
          return Chart;
        });
      }
    });
    // this.echartsComponnet.init((canvas, width, height) => {
    //   // 初始化图表
    //   const Chart = echarts.init(canvas, null, {
    //     width: width,
    //     height: height
    //   });
    //   Chart.setOption(option);
    //   // 注意这里一定要返回 chart 实例，否则会影响事件处理等
    //   return Chart;
    // });
  },
  getOption: function (data) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中
    var legendList = []
    for (var i in that.data.series) {
      var obj = {
        name: that.data.series[i].name,
        icon: 'circle',
        textStyle: {
          color: '#000000',
        }
      }
      legendList.push(obj)

      that.data.series[i].data.reverse()
    }
    var option = {
      title: {
        // text: 'Referer of a Website',
        // subtext: 'Fake Data',
        left: 'right'
      },
      // tooltip: {
      //   trigger: 'item'
      // },
      legend: {
        orient: 'vertical',
        // top:'30%',
        left: 'right',
        y: 'center',
        // data:{['sda','sdfs']},
        data: [{
          name: '搜索引擎',
          icon: 'circle',
          textStyle: { fontWeight: 'bold', color: 'orange' }
        }, '直接访问', '邮件营销', '联盟广告', '视频广告']
      },
      color: ['#5470C6', '#91CC75', '#FAC858', '#EE6666', '#fc8251', '#58fa8e', '#5891fa', '#fa9358', '#eafa58', '#8358fa','#6bfa58','#faa658','#fa5865','#e758fa','#e26640'],
      series: [
        {
          name: 'Access From',
          type: 'pie',
          radius: '50%',
          itemStyle:{
            normal:{
              labelLine:{
                length:0,
                show:that.data.nochartdata1==true?true:false
              }
            }
          },
          label: {
            position: 'outer',
            alignTo: 'none',
            margin: 0
          },
          left: '5%',
          right: "5%",
          top: 0,
          bottom: 0,
          tooltip: {
            trigger: 'item'
          },
          legend: {
            orient: 'vertical',
            left: 'right'
          },
          data: data,
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowOffsetX: 0,
              shadowColor: 'rgba(0, 0, 0, 0.5)'
            }
          }
        }
      ]
    }
    return option
  },
  getOption2: function (data) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中
    var legendList = []
    for (var i in that.data.series) {
      var obj = {
        name: that.data.series[i].name,
        icon: 'circle',
        textStyle: {
          color: '#000000',
        }
      }
      legendList.push(obj)

      that.data.series[i].data.reverse()
    }
    // console.log('数据',data)
    var app = {};
    let seriesdata=[];
    if (data[0].length!=0) {
      for(let a=1; a<=data[0].length-1; a++){
        seriesdata.push( {
          type: 'bar',
          barGap: '0%',
        })
      }
    }
    // console.log('seriesdata',seriesdata)
    var option;

    option = {
      legend: {
        show:false
      },
      dataset: {
        source: data
      },
      textStyle: {
        fontSize: 10
      },
      color: ['#5470C6', '#91CC75', '#EE6666', '#FAC858', '#6023f0', '#fa7058', '#58fa8e', '#5891fa', '#fa9358','#eafa58','#8358fa','#6bfa58','#faa658','#fa5865','e758fa'],
      grid: {
        left: '0',
        right: '0',
        top: '10',
        bottom: '40',
        containLabel: true
      },
      tooltip: {
        show: false
      },
      xAxis: { type: 'category' },
      yAxis: {

      },
      // Declare several bar series, each will be mapped
      // to a column of dataset.source by default.
      series:seriesdata
      //  [

      //   {
      //     type: 'bar',
      //     barGap: '0%',
      //   }, { type: 'bar', barGap: '0%', }, { type: 'bar', barGap: '0%', }, { type: 'bar', barGap: '0%', }, { type: 'bar', barGap: '0%', }]
    };
    return option
  },
  getOption3: function (data) {

    var option = {
      disableTouch:true,
      // title: {
      //   text: 'World Population'
      // },
      tooltip: {
        show: false,
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      label: {
        show: true,
        position: 'right',
        // valueAnimation: true
      },
      legend: {
      },
      grid: {
        left: '80',
        right: '10%',
        bottom: '10%',
        containLabel: false
      },
      xAxis: {
        type: 'value',
        boundaryGap: [0, 0.01],
        axisLabel: {
          interval: 0,
          fontSize: 8,
        }
      },
      yAxis: {
        type: 'category',
        data: data.title,
        // axisLabel:{
        //   interval:0,
        //   margin:80,
        //   fontSize: 10,
        //   textStyle: {
        //       align:'left',
        //       baseline:'middle'
        //   }
        //  },
        axisLabel: {
          align: "left",
          interval: 'auto',
          margin: '80',
          fontSize: 10,
          rich:{},
          formatter: function (params) {
            var newParamsName = ''
            var paramsNameNumber = params.length
            var provideNumber = 11 // 一行显示几个字
            var rowNumber = Math.ceil(paramsNameNumber / provideNumber)
            if (paramsNameNumber > provideNumber) {
              for (var p = 0; p < rowNumber; p++) {
                var tempStr = ''
                var start = p * provideNumber
                var end = start + provideNumber
                if (p === rowNumber - 1) {
                  tempStr = params.substring(start, paramsNameNumber)
                } else {
                  tempStr = params.substring(start, end) + '\n'
                }
                newParamsName += tempStr
              }
            } else {
              newParamsName = params
            }
            return newParamsName
          }


        }
      },
      series: [
        {
          // name: '2011',
          type: 'bar',
          barWidth: 18,
          data: data.num,
          label: {
            show: true,
            position: 'right',
            fontWeight: 'bold',
            textStyle: {
              color: "#EE6666",
            },
          },

        }

      ]
    };
    return option;
  },
  getOption4: function (data) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中

    var option = {
      tooltip: {
        show: false,
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      grid: {
        left: '0',
        right: '0',
        bottom: '10%',
        top: '15%',
        containLabel: true
      },
      xAxis: [
        {
          type: 'category',
          data: data.month,

          axisTick: {
            alignWithLabel: true
          },
          axisLabel: {
            textStyle: {
              color: function (value, index) {
                // console.log('that.data.month',that.data.month)
                //通过判断选中的名字改变柱子的颜色样式
                if (that.data.month == value) {
                  return '#D6000F';
                } else {
                  return '#020113';
                }
              }
            }
          }
        }
      ],

      yAxis: [
        {
          type: 'value'
        }
      ],
      label: {
        // normal: {
        show: true,
        position: 'top',
        margin: 0,
        color: 'inherit',
        // rich: {
        //   img: {
        //     backgroundColor: {
        //       image: '../image/icon_leijishouyi_50x50.png' //注意路径带不带/
        //     },
        //     color: "#fff",
        //     height: 30,
        //     align: 'center'
        //   }
        // },
        // border

        // backgroundColor: {
        //   image: '../image/icon_leijishouyi_50x50.png'  // 这是vue写法，不是的按原来的写就行
        // },
        formatter: function (params) {
          // console.log("params", params)
          // if(that.data.monthindex == params.dataIndex){
          //   console.log('dasfdasfdsafdsasddsdsf')
          //   return params.color='#D6000F'
          // }else {
          //   console.log('dasfdasfdsafdsasddsdsdsfsdafdsaff')
          // }
          // && that.data.monthindex == params.dataIndex
          if (params.value > 0&&params.dataIndex==that.data.selectmonth) {
            return '{color1|'+ params.value + '个'+'}';
          } else {
            return "";
          }
        },
          //  backgroundColor: '#D6000F', //标签背景颜色
          //  borderColor: '#D6000F',  //外层边框颜色
           borderWidth: 1, //外层边框宽度
           borderRadius: 4, //外层边框圆角

           rich:{
            color1:{
              color: '#D6000F',
              height: 14,
              padding: [0, 2, 0, 2],
              align: 'left',
              
            }
           },
      },
      series: [
        {
          name: 'Direct',
          type: 'bar',
          barWidth: '18',

          data: data.num,


        }
      ]
    };
    return option;
  },
  getOption5: function (data) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中

    var option = {
      tooltip: {
        show: false,
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      grid: {
        left: '16',
        right: '16',
        bottom: '20%',
        top: '10%',
        containLabel: true
      },
      xAxis: [{
        type: 'category',
        data: data.month,
        axisTick: {
          alignWithLabel: true
        },
        axisLabel: {
          textStyle: {
            color: function (value, index) {
              //通过判断选中的名字改变柱子的颜色样式
              if (that.data.quarter === value) {
                return '#D6000F';
              } else {
                return '#020113';
              }
            }
          }
        }

      }],
      label: {
        show: true,
        position: 'top',
        formatter: function (params) {
          // if(that.data.monthindex == params.dataIndex){
          //   return params.color='#D6000F'
          // }else {
         
          // }
          // && that.data.monthindex == params.dataIndex
          if (params.value > 0) {
            return  params.value + '个';
          } else {
            return "";
          }
        },
      },
      yAxis: [{
        type: 'value'
      }],
      series: [{
        name: 'Direct',
        type: 'bar',
        barWidth: '18',
        data: data.num,

      }]
    };
    return option;
  },


  // 营业额配置
  getOptionyye: function (date,num) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中

    var option = {
     
      grid: {
        left: '5%',
        right: '5%',
        bottom: '0%',
        top: '15%',
        containLabel: true
      },
      xAxis: {
        type: 'category',
        triggerEvent:true,
        data: date,
        axisLabel: {
          textStyle: {
            color: function (value, index) {
              console.log('that.data.month',that.data.month)
              //通过判断选中的名字改变柱子的颜色样式
              if (that.data.month == value) {
                return '#D6000F';
              } else {
                return '#020113';
              }
            }
          }
        },
      },
      label: {
        // normal: {
        show: true,
        position: 'top',
        margin: 0,
        color: 'inherit',
        formatter: function (params) {
          if (params.dataIndex==that.data.selectmonth) {
            return '{color1|'+ params.value +'}';
          } else {
            return "";
          }
        },
           backgroundColor: '#FFFFFF', //标签背景颜色
          //  borderColor: '#D6000F',  //外层边框颜色
           borderWidth: 1, //外层边框宽度
           borderRadius: 4, //外层边框圆角

           rich:{
            color1:{
              color: '#D6000F',
              height: 14,
              padding: [0, 2, 0, 2],
              align: 'left',
              
            }
           },
      },
      yAxis: {
        type: 'value'
      },
      
      // grid:{
      //   left:'left'
      // },
      series: [
        {
          data: num,
          type: 'line',
          smooth: true,
          // symbolSize: 6,
        }
      ]
    };
    return option;
  },
   // 人员配置
   getOptionry: function (date,num) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中

    var option = {
     
      grid: {
        left: '5%',
        right: '5%',
        bottom: '0%',
        top: '15%',
        containLabel: true
      },
      xAxis: {
        type: 'category',
        triggerEvent:true,
        data: date,
        axisLabel: {
          textStyle: {
            color: function (value, index) {
              console.log('that.data.month',that.data.month)
              //通过判断选中的名字改变柱子的颜色样式
              if (that.data.month == value) {
                return '#D6000F';
              } else {
                return '#020113';
              }
            }
          }
        },
      },
      label: {
        // normal: {
        show: true,
        position: 'top',
        margin: 0,
        color: 'inherit',
        formatter: function (params) {
          if (params.dataIndex==that.data.selectmonth) {
            return '{color1|'+ params.value +'}';
          } else {
            return "";
          }
        },
           backgroundColor: '#FFFFFF', //标签背景颜色
          //  borderColor: '#D6000F',  //外层边框颜色
           borderWidth: 1, //外层边框宽度
           borderRadius: 4, //外层边框圆角

           rich:{
            color1:{
              color: '#D6000F',
              height: 14,
              padding: [0, 2, 0, 2],
              align: 'left',
              
            }
           },
      },
      yAxis: {
        type: 'value'
      },
      
      // grid:{
      //   left:'left'
      // },
      series: [
        {
          data: num,
          type: 'line',
          smooth: true,
          // symbolSize: 6,
        }
      ]
    };
    return option;
  },
   // 工地配置
   getOptiongd: function (date,num) {
    var that = this
    // 前台配置折线线条表示属性
    // 使用for in 遍历对象拿出name,并配置icon和textStyle，最后放入新建的legendList数组中

    var option = {
     
      grid: {
        left: '5%',
        right: '5%',
        bottom: '0%',
        top: '15%',
        containLabel: true
      },
      xAxis: {
        type: 'category',
        triggerEvent:true,
        data: date,
        axisLabel: {
          textStyle: {
            color: function (value, index) {
              console.log('that.data.month',that.data.month)
              //通过判断选中的名字改变柱子的颜色样式
              if (that.data.month == value) {
                return '#D6000F';
              } else {
                return '#020113';
              }
            }
          }
        },
      },
      label: {
        // normal: {
        show: true,
        position: 'top',
        margin: 0,
        color: 'inherit',
        formatter: function (params) {
          if (params.dataIndex==that.data.selectmonth) {
            return '{color1|'+ params.value +'}';
          } else {
            return "";
          }
        },
           backgroundColor: '#FFFFFF', //标签背景颜色
          //  borderColor: '#D6000F',  //外层边框颜色
           borderWidth: 1, //外层边框宽度
           borderRadius: 4, //外层边框圆角

           rich:{
            color1:{
              color: '#D6000F',
              height: 14,
              padding: [0, 2, 0, 2],
              align: 'left',
              
            }
           },
      },
      yAxis: {
        type: 'value'
      },
      
      // grid:{
      //   left:'left'
      // },
      series: [
        {
          data: num,
          type: 'line',
          smooth: true,
          // symbolSize: 6,
        }
      ]
    };
    return option;
  },
  // 我的家
  getMyHome() {
    let t = this
    wx.showLoading({
      title: '加载中...', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + 'getMyHome',
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
      },
      success: res => {
        wx.hideLoading();
        console.log(res)
        res.data.myHomeList.map(item => item.isshow = false)
        if (res.data.result == 0) {
          this.setData({
            myHomeList: res.data.myHomeList
          })
          // this.getOrderDetails(this.data.myHomeList[0].id)
        } else {
          wx.showToast({
            title: res.data.message,
            duration: 2500, //持续的时间
            icon: 'none', //图标
          })
        }





      },
      fail: err => {
        wx.showToast({
          title: '请求失败',
          duration: 2500, //持续的时间
            icon: 'none', //图标
        })
      }
    })
  },
  showtwo(e) {
    let index = e.currentTarget.dataset.index
    let myHomeList = this.data.myHomeList
    if(myHomeList[index].projectStatus==2){
      myHomeList.forEach((item1, index1) => {
        if (index1 == index) {
          item1.isshow = !item1.isshow
        } else {
          item1.isshow = false
        }
      })
      this.setData({
        myHomeList: myHomeList
      }) 
    }else{
      let orderId = e.currentTarget.dataset.id
      wx.navigateTo({
        url: '/pages/projectDetails/projectDetails?orderId=' + orderId,
      })
    }
  },



  showteam(e) {
    let index = e.currentTarget.dataset.index
    let teamList = this.data.teamList
    teamList.forEach((item1, index1) => {
      if (index1 == index) {
        item1.isshow = !item1.isshow
      } else {
        item1.isshow = false
      }
    })
    this.setData({
      teamList: teamList
    }) 
  },


  godetail(e) {
    let orderId = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/projectDetails/projectDetails?orderId=' + orderId,
    })
  },
  goaddRelatives() {
    wx.navigateTo({
      url: '/pages/addrelatives/addrelatives',
    })
  },


  updateUserInfo(wxHeadImage) {
    let t = this
    wx.showLoading({
      title: '加载中。。。', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + 'updateUserInfo',
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        wxHeadImage: wxHeadImage
      },
      success: res => {
        wx.hideLoading();
        console.log(res)

        if (res.data.result == 0) {
          t.setData({
            userwximage: res.data.user.wxHeadImage
          })
          wx.showToast({
            title: '更新成功',
            duration: 2500, //持续的时间
            icon: 'none', //图标
          })
          // this.getOrderDetails(this.data.myHomeList[0].id)
        } else {
          wx.showToast({
            title: res.data.message,
            duration: 2500, //持续的时间
            icon: 'none', //图标
          })
        }





      },
      fail: err => {
        wx.showToast({
          title: '请求失败',
          duration: 2500, //持续的时间
          icon: 'none', //图标
        })
      }
    })
  },
  // 上传附件
  upload(arr) {
    return new Promise((reslove, reject) => {
      if (arr.length == 0) {
        reslove([])
        return
      }
      wx.showLoading({
        title: '上传中...', //提示的内容
        mask: true //显示透明蒙层 防止触摸穿透
      })
      let finishFilesList = []
      arr.forEach((item, index) => {
        wx.uploadFile({
          url: app.globalData.Interfaceurl + 'saveFileUpload',
          filePath: item,
          name: 'file',
          formData: {
            userId: app.globalData.userId,

          },
          header: {
            "content-type": "multipart/form-data"
          },
          success: function (res) {
            finishFilesList.push(JSON.parse(res.data).fileUrl)
            if (index >= arr.length - 1) {
              setTimeout(()=>{
                wx.hideLoading();
                reslove(finishFilesList)
               },500)
            }
          },
          fail: err => {
            return err
          }
        })
      })
    })


  },

  async bindchooseavatar(e) {

    this.setData({
      userwximage: e.detail.avatarUrl
    })
    let urls = await this.upload([e.detail.avatarUrl])
    let url = app.globalData.Imageurl + urls[0]
    

    this.updateUserInfo(url)
  },

  getNearShopList() {
    let t = this
    wx.showLoading({
      title: '加载中。。。', //提示的内容
      mask: true //显示透明蒙层 防止触摸穿透
    })
    wx.request({
      url: app.globalData.Interfaceurl + 'getNearShopList',
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: app.globalData.userId,
        shopLongitude: t.data.longitude,
        shopLatitude: t.data.latitude
      },
      success: res => {
        wx.hideLoading();
        console.log(res)

        t.setData({
          shopList: res.data.shopList,
          isshowyyfw:false
        })





      },
      fail: err => {
        wx.showToast({
          title: '请求失败',
          duration: 2500, //持续的时间
          icon: 'none', //图标
        })
      }
    })
  },

  //选择身份切换
  idshow(){
    // wx.navigateTo({
    //   url: '/pages/my/pageswitch/pageswitch.js',
    // })
    this.setData({
      isidtypeshow:!this.data.isidtypeshow
    })
  },
  ghxx(e){
    let that=this
    new Promise(function (resolve, reject) {
      //...
      resolve(app.wxlogin(e.currentTarget.dataset.id))
    }).then(function(){
      // that.onLoad()
     that.onShow()
     that.setData({
      isidtypeshow:false
     })
     console.log('dsfdsfdasfdasfdsdfs')
     let myTab = that.selectComponent('#myTab'); // 页面获取自定义组件实例
     console.log('dsfdsfdasfdasfdsdfs',myTab)
    myTab.gettabList(); // 通过实例调用组件事件
    if (app.globalData.identity == 7||app.globalData.identity == 9) {
      this.setData({
        Imageurl: app.globalData.Imageurl,
        token:app.token(),
      })
      this.getMyHome()
      this.getFamilyList()
    }
    })
    // app.wxlogin(e.currentTarget.dataset.id)
   
    
    // that.onLoad()
    // that.onShow()
    
    // wx.reLaunch({
    //   url: '/pages/index/index',
    // })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log(this.data.userid,'useridsss',app.globalData.userId)
    // 正常使用逻辑 
    //   if (this.selectComponent) {     
    //   } 
    //   else {     wx.showModal({title:'提示', content:'微信版本太低，请更新微信版本'}); 
    // }

    let now=new Date()
    if (now.getHours()>=18||now.getHours()<=5) {
      this.setData({
        hour:'晚上好'
      })
    }else if(now.getHours()<=11&&now.getHours()>5){
      this.setData({
        hour:'上午好'
      })
    }else if(now.getHours()>=12&&now.getHours()<18){
      this.setData({
        hour:'下午好'
      })
    }
  
    this.getuserinfofun()
    this.setData({
      selectindex: 3
    })
    this.setData({
      identity: app.globalData.identity

    })


    this.getinformation(this.data.identity)

    let myTab = this.selectComponent('#myTab'); // 页面获取自定义组件实例
    myTab.gettabList(); // 通过实例调用组件事件
    if (app.globalData.identity == 7||app.globalData.identity == 9) {
      this.setData({
        Imageurl: app.globalData.Imageurl,
        token:app.token(),
      })
      this.getMyHome()
      this.getFamilyList()
    }


    if (app.globalData.identity == 0) {
      let t = this
      wx.getLocation({
        success(res) {
          console.log(res)
          t.setData({
            latitude: res.latitude,
            longitude: res.longitude,
            isfujin: true,
            isshowyyfw:false,

          })
          t.getNearShopList()
        },
        fail(e){
          t.setData({
            isshowyyfw:true,
          })
          console.log(e)
        }
      })
    }



  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
    let now=new Date()
    if (now.getHours()>=18||now.getHours()<=5) {
      this.setData({
        hour:'晚上好'
      })
    }else if(now.getHours()<11&&now.getHours()>5){
      this.setData({
        hour:'上午好'
      })
    }else if(now.getHours()>=12&&now.getHours()<18){
      this.setData({
        hour:'下午好'
      })
    }


    if (!this.data.isonLoad) {

      this.getuserinfofun()
      this.setData({
        selectindex: 3
      })
      this.setData({
        identity: app.globalData.identity
  
      })
  
  
      this.getinformation(this.data.identity)
  
      let myTab = this.selectComponent('#myTab'); // 页面获取自定义组件实例
      myTab.gettabList(); // 通过实例调用组件事件
      if (app.globalData.identity == 7||app.globalData.identity == 9) {
        this.setData({
          Imageurl: app.globalData.Imageurl,
          token:app.token(),
        })
        this.getMyHome()
        this.getFamilyList()
      }




      if (app.globalData.identity == 0) {
        let t = this
        wx.getLocation({
          success(res) {
            t.setData({
              latitude: res.latitude,
              longitude: res.longitude,
              isfujin: true
            })
            t.getNearShopList()
          }
        })

      }
     
    } else {
      this.setData({
        isonLoad: false
      })
    }


    
  },

  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },



  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if (this.data.pageNo < this.data.toalpages) {
      this.setData({
        pageNo: this.data.pageNo + 1
      })
      // console.log(this.data.pageNo)
      switch (this.data.identity) {
        case '4':
          this.getSuperviseFinishProjectPage()
          break;
        case '5':
          this.getShopownerFinishProjectPage()
          break;
        case '6':
          this.getBricklayFinishProjectPage()
          break;
        case '8':
          this.getDesignerFinishProjectPage()
          break;
        case '10':
          this.getAdviserFinishProjectPage()
          break;

        default:
          break;
      }


    }

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})